<?php
/**
 * alltosun.com  LoginController.Class.php
 * ============================================================================
 * 版权所有 (C) 2015 齐齐哈尔大学计算机与控制工程学院，并保留所有权利。
 * ============================================================================
 * $Author: 范志俊 (fanfzj@163.com) $
 * $Date: 2015-10-22 上午12:24:54 $
 */
namespace Admin\Controller;
use Think\Controller;
class LoginController extends Controller {
    //后台登录页面
    public function index()
    {
        $site_img=get_config_value('site_img');
        if(empty($site_img))
        {
            $site_img=__ROOT__.'/Public/Images/background.jpg';
        }
        $site_name=get_config_value('site_name');
        $this->assign('site_img',$site_img);
        $this->assign('site_name',$site_name);
    	$this->display(':login');
    }

    //检验管理员登录是否正确
    public function check()
    {
        $admin_name     = I('admin_name', '');
        $admin_password = I('admin_password', '');

        if((get_config_value('admin_username')==$admin_name)&&(get_config_value('admin_password')==$admin_password)){
            session('admin_id',md5($admin_name.$admin_password.date('y-m-d h:i:s',time())));
            session('admin_name',$admin_name);
            $callback = U('admin/index/index');
            $data = array(
            	'info' => 'ok',
            	'callback' => $callback
            );
        }else{
            $data = array(
                    'info' => '登录失败，请检查登录名和密码是否正确'
            );
        }

        $this->ajaxReturn($data);
    }

}